const Path = require('path');

module.exports = function ({ content, path, option }) {
    const SVGO = require(Path.resolve(option.nmodulePath, './svgo'));
    let name = Path.basename(path).split('.').shift();
    const svgo = new SVGO(option.compiler.icon || {});
    return new Promise(resolve => {
        svgo.optimize(content, { path }).then(({ data }) => {
            resolve("module.exports={name:'x-icon-" + name + "',info:{template(){return \`" + data + "\`;},selfClose: true}}");
        });
    });
};